//
//  BGJinDuViewController.m
//  bigMall
//
//  Created by ios on 16/8/3.
//  Copyright © 2016年 thinklev. All rights reserved.
//

#import "BGJinDuViewController.h"
#import "BGSellerell.h"

@interface BGJinDuViewController () <UITableViewDelegate,UITableViewDataSource> {
    
    UITableView *_tableView;
    NSArray *_dataArr;
    
}

@end

@implementation BGJinDuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self createUi];
    [self initDat];
    NSLog(@"%@",self.typeId);
    
}

- (void)initDat {
//    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"准备确认订单"];
//    [str addAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor],NSForegroundColorAttributeName, nil] range:NSRangeFromString(@"准备确认订单")];
    _dataArr = [NSArray arrayWithObjects:@"准备确认订单",@"等待买家付款",@"进行备货",@"等待买家付中期款",@"等待买家验收提货",@"等待买家验收发票",@"等待买家付尾款",@"等待评价",@"已完成", nil];
    
}

- (void)createUi {
    
    _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    
    _tableView.delegate = self;
    _tableView.dataSource = self;
    
    [self.view addSubview:_tableView];
    
}

#pragma mark - dataSource -
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 10;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    
    return 1;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.row == 0) {
        
        return 59;
        
    } else {
        
        return 65;
        
    }
}

#pragma mark - delegate -
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.row == 0) {
        
        [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"celId"];
        
        UITableViewCell *cel = [tableView dequeueReusableCellWithIdentifier:@"celId" forIndexPath:indexPath];
        
        cel.textLabel.text = @"进度跟踪";
        cel.textLabel.font = [UIFont systemFontOfSize:18];
        cel.selectionStyle = UITableViewCellSelectionStyleNone;
        
        return cel;
        
    }else {
        
        [tableView registerNib:[UINib nibWithNibName:@"BGSellerell" bundle:nil] forCellReuseIdentifier:@"celId"];
        BGSellerell *cel = [tableView dequeueReusableCellWithIdentifier:@"celId" forIndexPath:indexPath];
        cel.selectionStyle = UITableViewCellSelectionStyleNone;
        
        cel.lable.text = _dataArr[indexPath.row - 1];
        cel.btn.clipsToBounds = YES;
        cel.btn.layer.cornerRadius = 12;
        
        if (indexPath.row == 1) {
            
            cel.shang.hidden = YES;
            
        }
        if (indexPath.row == 9) {
            
            cel.xiamian.hidden = YES;
            
        }
        
        if (indexPath.row == [self.typeId intValue] + 1) {
            
            cel.btn.backgroundColor = [UIColor redColor];
            [cel.lable setTextColor:[UIColor redColor]];
            
        }
        
        return cel;
        
    }
   
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        
        if (indexPath.row == 0) {
            
            tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
            
            [cell setSeparatorInset:UIEdgeInsetsZero];
            
        }
    }
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        if (indexPath.row == 0) {
            
            [cell setLayoutMargins:UIEdgeInsetsZero];
            
        }
        
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
